package org.skyui.beanmanagers;

import java.lang.reflect.Constructor;

import org.skyui.beans.AbstractBean;


public class CommandManager extends BeanSetManager {

	protected CommandManager(Class beanClass) {
		super(beanClass);
	}

	
	@Override
	public AbstractBean createTemplate() { 
		throw new Error("Should never be called");
	}
	
	public AbstractBean createTemplate(AbstractBean b) {
		Constructor cons;
		try {
			cons = beanTemplateClass.getConstructor(new Class[] { AbstractBean.class });
		} catch (SecurityException e) {
			throw new Error(e);
		} catch (NoSuchMethodException e) {
			throw new Error(e);
		}
		try {
			AbstractBean cb =  (AbstractBean) cons.newInstance(new Object[] { b });
			cb.setOrganization(b.getOrganization());
			return cb;
		} catch (Exception e) {
			throw new Error("Could not find template class", e);
		}
	}	
}
